﻿//http://www.21andy.com/blog/20090530/1313.html
var digi = 2;

function StockInfo() {
    this.code = "";     //代码
    this.name = "";         //名称
    this.tradetime = "";    //行情日期
    this.realprice = "";     //最近成交价
    this.todayopen = "";     //今日开盘价
    this.yesterday = "";     //昨日收盘价
    this.maximum = "";       //最高成交价
    this.minimum = "";       //最低成交价
    this.volume = "";        //成交数量
    this.amount = "";        //成交金额
    this.changeAmt = "";         //涨跌额
    this.changeRate = "";      //涨跌幅
    this.buyVolumes = new Array(5); 
    this.saleVolumes = new Array(5);
    this.buyPrices = new Array(5);
    this.salePrices = new Array(5);
}

StockInfo.prototype.getChangeAmt = function () { //涨跌额
    var diff = parseFloat(this.realprice) - parseFloat(this.yesterday);
    return this.realprice == 0 ? "--" : diff.toFixed(digi)
}

StockInfo.prototype.getChangeRate = function () { //涨跌幅
    var diff = parseFloat(this.realprice) - parseFloat(this.yesterday);
    return this.realprice == 0 ? "--" : ((100 * diff / this.yesterday).toFixed(digi) + "%") 
}